package cn.telling.common.tools.message.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.telling.common.pager.PageVo;
import cn.telling.common.tools.message.dao.IMessageInfoDao;
import cn.telling.common.tools.message.service.IMessageInfoService;
import cn.telling.common.tools.message.vo.MessageInfoVo;
/**   
 * @Title: MessageInfoServiceImpl.java 
 * @Package com.ordermanager.service.impl 
 * @Description: TODO(描述该文件做什么) 
 * @author 薛松坛   
 * @date 2013-3-28 上午9:10:34 
 * @version V1.0   
 */
@Service("messageInfoService")
public class MessageInfoServiceImpl implements IMessageInfoService {
	@Autowired
	@Qualifier("messageInfoDao")
	private IMessageInfoDao messageInfoDao;


	public IMessageInfoDao getMessageInfoDao() {
		return messageInfoDao;
	}

	public void setMessageInfoDao(IMessageInfoDao messageInfoDao) {
		this.messageInfoDao = messageInfoDao;
	}
	/**
	 * @Description: 新增消息。
	 * @param		参数说明
	 * @return		返回值
	 * @author      薛松坛
	 * @date 2013-3-28 上午10:59:12 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.NESTED,rollbackFor={Exception.class})
	public int insertMessageInfo(MessageInfoVo vo) {
		// TODO Auto-generated method stub
		return messageInfoDao.insertMessageInfo(vo);
	}
	/**
	 * @Description: 获取当前登录人消息列表。
	 * @param		参数说明
	 * @return		当前登录人未读消息列表
	 * @author      薛松坛
	 * @date 2013-3-26 下午4:47:28 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public List<MessageInfoVo> getMessageInfoLs(MessageInfoVo vo, PageVo pageVo) {
		// TODO Auto-generated method stub
		return messageInfoDao.getMessageInfoLs(vo,pageVo);
	}
	/**
	 * @Description: TODO 按条件查询当前登录人信息数量。
	 * @param		参数说明
	 * @return		当前登录人未读信息数量
	 * @author      薛松坛
	 * @date 2013-3-26 下午4:47:28 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int getMessageCount(MessageInfoVo vo) {
		// TODO Auto-generated method stub
		return messageInfoDao.getMessageCount(vo);
	}
	/**
	 * @Description: TODO 按条件查询当前登录人未读信息数量。
	 * @param		参数说明
	 * @return		当前登录人未读信息数量
	 * @author      薛松坛
	 * @date 2013-3-26 下午4:47:28 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int getNotReadMsgCount(MessageInfoVo vo) {
		// TODO Auto-generated method stub
		return messageInfoDao.getNotReadMsgCount(vo);
	}
	/**
	 * @Description:消息更新
	 * @param		参数说明
	 * @return		消息更新标示
	 * @author      薛松坛
	 * @date 2013-3-27 下午3:31:41 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int updateMessageInfo(MessageInfoVo vo) {
		// TODO Auto-generated method stub
		return messageInfoDao.updateMessageInfo(vo);
	}
	/**
	 * @Description:更新删除标示为是
	 * @param		参数说明
	 * @return		消息更新标示
	 * @author      薛松坛
	 * @date 2013-3-27 下午3:31:41 
	 * @version V1.0
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int deleteMessageInfo(MessageInfoVo vo) {
		// TODO Auto-generated method stub
		return messageInfoDao.deleteMessageInfo(vo);
	}
	/**
	 * 批量更新消息信息
	 * @param updateLst
	 * @return
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int updateMessageInfoBatch(List<MessageInfoVo> updateLst) {
		// TODO Auto-generated method stub
		return messageInfoDao.updateMessageInfoBatch(updateLst);
	}
	/**
	 * 批量更新删除标示为是
	 * @param updateLst
	 * @return
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int deleteMessageInfoBatch(List<MessageInfoVo> deleteLst){
		// TODO Auto-generated method stub
		return messageInfoDao.deleteMessageInfoBatch(deleteLst);
	}
	/**
	 * 消息批量插入
	 * @param updateLst
	 * @return
	 */
	@Override
	@Transactional(value="txManager",isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,rollbackFor={Exception.class})
	public int insertMessageInfoBatch(List<MessageInfoVo> insertLst){
		int num=0;
		if(insertLst!=null&&insertLst.size()>0){
			for (int i = 0; i < insertLst.size(); i++) {
				num =num+messageInfoDao.insertMessageInfo(insertLst.get(i));
			}
		}
		return num;
	}
}
